package com.lei.synchronized_upgrade;

import com.lei.synchronized_upgrade.annotation.Info;
import org.openjdk.jol.info.ClassLayout;

/**
 * @Author: Doream
 * @Date: 2022/3/18 21:59
 */
@Info("测试学习类。")
public class Test {
    public static void main(String[] args) throws ClassNotFoundException {
        Class<?> aClass = Class.forName("");
    }

    @Info("查看对象的结构方法：viewObjectStructure")
    public void viewObjectStructure(){
        ObjectStructure object = new ObjectStructure();
        System.out.println(ClassLayout.parseInstance(object).toPrintable());
        /**
         *         com.lei.synchronized_upgrade.ObjectStructure object internals:
         *         OFF  SZ               TYPE DESCRIPTION               VALUE
         *         0   8                    (object header: mark)     0x0000000000000005 (biasable; age: 0)
         *         8   4                    (object header: class)    0x00067248
         *         12   4                int ObjectStructure.x         0
         *         16   1            boolean ObjectStructure.flag      false
         *         17   3                    (alignment/padding gap)
         *         20   4   java.lang.String ObjectStructure.name      (object)
         *         Instance size: 24 bytes
         *         Space losses: 3 bytes internal + 0 bytes external = 3 bytes total
         */
    }
}
